﻿namespace Sgr.Generator
{
    /// <summary>
    /// 基于数据库号段实现Id生成
    /// </summary>
    public interface ISegmentNumIdGenerator : IDisposable
    {
        /// <summary>
        /// 初始化
        /// <param name="cancellationToken">取消令牌</param>
        /// </summary>
        Task<bool> InitAsync(CancellationToken cancellationToken = default);

        /// <summary>
        /// 生成不重复的长整型唯一标识
        /// </summary>
        /// <param name="key"></param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns></returns>
        Task<long> GetUniqueIdAsync(string key = "", CancellationToken cancellationToken = default);
    }
}